<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<link rel="stylesheet" href="__PUBLIC__/css/inc.css" />
	<link rel="stylesheet" href="__PUBLIC__/css/ico.css" />
	<hdjs/>
	<script type="text/javascript">
		var postUrl = '__CONTROL__/selectCate';
	</script>
	<script type="text/javascript" src='__PUBLIC__/js/extend.js'></script>
	<script type="text/javascript" src='__CONTROL_TPL__/js/js.js'></script>
	<title>修改商品</title>
</head>
<body>
	<div class="Menu">
		<a href="{|U:'index'}">商品管理</a>
		<a href="{|U:'add'}"  onclick='return selectCate(this);'>添加商品</a>
		<a href="{|U:'updateCache'}">更新缓存</a>
		<a class="act">修改商品</a>
	</div>
	<form method="post" enctype='multipart/form-data'>
		<div class="tabMenu">
			<a href="" class="act">商品基本属性</a>
			<a href="">商品其他属性</a>
			<a href="">商品详细内容</a>
			<a href="">商品图片</a>
		</div>
		<ul class="tabSub">
			<li class="act">
				<table class="form table">
					<tr>
						<th colspan='2'>商品基本属性</th>
						<input type="hidden" name='pid' value='{$hd.get.pid|default:0}' />
					</tr>
					<tr>
						<td class="tr f14 fm pct15"><span class="pr10">商品名称</span></td>
						<td><input name='gname' type="text" class='ml10 pct60' value="{$field.gname}" /></td>
					</tr>
					<tr>
						<td class="tr f14 fm"><span class="pr10">所属栏目</span></td>
						<td>
							<input name="cid" value="{$cate.cid}" type="hidden">
							<span class="ml10">{$cate.cname}</span>
						</td>
					</tr>
					<if value="!$aspec[0]">
						<tr>
							<td class="tr f14 fm pct15"><span class="pr10">库存</span></td>
							<td><input value="{$field.stock}" name='stock' type="text" class='ml10 pct20' /></td>
						</tr>
						<tr>
							<td class="tr f14 fm pct15"><span class="pr10">价格</span></td>
							<td><input value="{$field.price}" name='price' type="text" class='ml10 pct20' /></td>
						</tr>
						<tr>
							<td class="tr f14 fm pct15"><span class="pr10">商品货号</span></td>
							<td><input value="{$field.goods_sn}" name='goods_sn' type="text" class='ml10 pct30' /></td>
						</tr>
					</if>
					<tr>
						<td class="tr f14 fm"><span class="pr10">商品属性</span></td>
						<td>
							<table class='table ml10 pct90 bgwhite bdd'>
								<list from="$aclass" name="ac">
									<tr>
										<td class="tr f14 fm pct15"><span class="pr10">{$ac.attr_name}</span></td>
										<td><p class='ml10' />{$ac.html}</td></td>
									</tr>
								</list>
							</table>	
						</td>
					</tr>
				<if value="$aspec[0]">
					<tr>
						<td class="tr f14 fm"><span class="pr10">商品规格</span></td>
						<td>
							<table class='table ml10 pct90 bgwhite bdd' id="spec">
								<tr>
									<list from="$aspec[0]" name="ac">
										<th class="tl f14 fm pct15"><span class="pr10">{$ac.attr_name}</span></th>
									</list>
									<th>库存</th>
									<th>价格</th>
									<th>商品货号</th>
									<th class='tc fv b pct10'><a href="" class="addSpec gray"><i class="ico icoadd"><c></i>增</a></th>
								</tr>
								<foreach from="$stock" value="$st" key="$k">
									<tr>
										<list from="$aspec[$k]" name="ac">
											<td class="tl f14 fm pct15">
												<span class="pr10">{$ac.html}</span>
											</td>
										</list>
										<td>
											<input value="{$st.stid}" class="pct50" type="hidden" name="spec[stid][]" />
											<input value="{$st.stock}" class="pct50" type="text" name="spec[stock][]" /></td>
										<td><input value="{$st.price}" class="pct50" type="text" name="spec[price][]" /></td>
										<td>
											<input value="{$st.goods_sn}" class="pct80" type="text" name="spec[goods_sn][]" />
										</td>
										<td class="fv b tc"><a href="" class="delSpec red"><i class="ico icodec"><c></i>删</a></td>
									</tr>
								</foreach>
							</table>	
						</td>
					</tr>
				</if>
				</table>
			</li>
			<li>
				<table class="table form">
					<tr>
						<td class="tr f14 fm"><span class="pr10">上架时间</span></td>
						<td>
							<input name='addtime' type="text" class='ml10 pct20' id='updatetime' value="{$field.addtime|hd_date:'Y/m/d H:i:s'}" readonly="readonly" />
							<script type="text/javascript">
								$('#updatetime').calendar({format: 'yyyy/MM/dd HH:mm:ss'});
							</script>
						</td>
					</tr>
					<tr>
						<td class="tr f14 fm"><span class="pr10">商品属性</span></td>
						<td id='flag'>
							<label for="flag1" class='ml10 pct60'>
								<input type="checkbox" name='flag[]' id='flag1' value='推荐'/> 推荐
							</label>
							<label for="flag2" class='ml10 pct60'>
								<input type="checkbox" name='flag[]' id='flag2' value='置顶'/> 置顶
							</label>
							<script type="text/javascript">
								var f = "{$field.flag}",
									 flag = f.split(",");
								$('#flag :checkbox').each(function(){
									var v = $(this).val();
									for(var i in flag){
										if(flag[i]==v){
											$(this).attr('checked','checked');
										}
									}
								})
							</script>	
						</td>
					</tr>
					<tr>
						<td class="tr f14 fm"><span class="pr10">品牌</span></td>
						<td>
							<select name="bid" id="brand" class='ml10'>
								<option value="">==请选择品牌==</option>
								<list from="$brand" name='b'>
									<option value="{$b.bid}" pic="{$b.logo}" <if value="$field['bid'] eq $b['bid']">selected=""</if>>{$b.bname}</option>
							 	</list>
							</select>
							<span class="p5" id="brandLogo"><img src="__ROOT__/" alt="" /></span>
							<script type="text/javascript">
								var src = $('#brandLogo img').attr('src')+$('#brand').find('option:selected').attr('pic');
								$('#brandLogo img').attr('src',src);
							</script>	
						</td>
					</tr>
					<tr>
						<td class="tr f14 fm"><span class="pr10">关键字</span></td>
						<td><textarea class='ml10 pct70' name="keywords" id="" cols="30" rows="2">{$field.keywords}</textarea></td>
					</tr>
					<tr>
						<td class="tr f14 fm"><span class="pr10">栏目描述</span></td>
						<td><textarea class='ml10 pct70' name="description" id="" cols="30" rows="3">{$field.description}</textarea></td>
					</tr>
					<tr>
						<td class="tr f14 fm"><span class="pr10">售后服务</span></td>
						<td><textarea class='ml10 pct70' name="service" id="" cols="30" rows="3">{$field.service}</textarea></td>
					</tr>
				</table>
			</li>
			<li>
				<table class="table form">
					<tr>
						<td class="tr f14 fm pct10">详细内容</td>
						<td><ueditor name='body' content='{$field.body}' /></td>
					</tr>
				</table>
			</li>
			<li>
				<div class="form">
					<fieldset class='dib mr20'>
						<legend>首页图片</legend>
						<input type="file" name='index_pic' />
						<if value='$field.index_pic'>
							<div class="p2 bdc dib bgwhite-2 ml5 showPic">
								<img src="__ROOT__/{$field.index_pic}" height="50" />
								<input type="hidden" name='indexPic' value="{$path}{$field.index_pic}" />
							</div>
						</if>
					</fieldset>
					<fieldset class='dib'>
						<legend>列表图片</legend>
						<input type="file" name='list_pic' />
						<if value='$field.list_pic'>
							<div class="p2 bdc dib bgwhite-2 ml5 showPic rel">
								<img src="__ROOT__/{$field.list_pic}" height="50" />
								<input type="hidden" name='listPic' value="{$path}{$field.list_pic}" />
							</div>
						</if>
					</fieldset>
				</div>
				<div class="bdc mt20 f18 bgwhite-2 p10 rad5">
					<div class="form bgwhite p10 f14 rad2">
						<div class="p10">
							<list from='$pic' name='p'>
								<div class="bdc p2 rel dib mr5">
									<img src="__ROOT__/{$p.medium}" height='120' />
									<span class="delGoodsPic abs f16 t5 r5 bgblack white tc rad50 w25 h25 lh25 hand fv black bsd opa70 a" pid="{$p.pid}">X</span>
								</div>
							</list>
						</div>
						
						<fieldset id='pic' of>
							<legend>内容页图片</legend>
							<div class="p5 l mr5">
								<input type="file" name='pic[]' />
								<button type="button" class='btn bggreen2 f14' id='addPic'>增加图片</button>
							</div>
						</fieldset>
						<script type="text/javascript">
							$('#addPic').click(function(){
								var h = "<div class='p5 l mr5'><input type='file' name='pic[]' />\
											<button type='button' class='btn bgred3 f14' onclick='delPic(this);'>\
											删除图片</button></div>";
								$('#pic').append(h);
							})
							function delPic(id){
								$(id).parent().remove();
							}
						</script>
					</div>
				</div>
			</li>
		</ul>
		<input type="hidden" value='{$field.gid}' name='gid' />
		<div class="fixed b15 l15 fm bdc bgwhite opa80 p2">
			<p class="p5 tc"><input type="submit" class="btn bgteal1 f18" value='确定操作' /></p>
		</div>
	</form>
</body>
</html>